package com.ruoyi.logCen.task;

import com.ruoyi.logCen.dKafka.KafkaListenerService;
import com.ruoyi.logCen.domain.LogInfo;
import com.ruoyi.logCen.service.LogInfoService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 定时任务调度测试
 *
 * @author wbk
 */
@Component("kafkaTask")
public class KafkaTask {

    @Resource
    private LogInfoService logInfoService;
    @Resource
    private KafkaListenerService kafkaListenerService;

    public void runKafkaConsum() throws NoSuchMethodException {
        System.out.println("开始执行kafka消费者任务");


        List<LogInfo> logInfoList = logInfoService.getAllLogInfoGroupByTopic();

        for (LogInfo logInfo : logInfoList){
            kafkaListenerService.addListener(logInfo.getKafkaTopic(), logInfo.getKafkaGroup());
        }

    }



}
